/* 1662. 检查两个字符串数组是否相等 */
/**
 * @param {string[]} word1
 * @param {string[]} word2
 * @return {boolean}
 */
const join = (word) => {
	let ret = ''
	word.forEach((s) => {
		ret += s
	})
	return ret
}
// 方法一：拼接字符串进行对比
var arrayStringsAreEqual = function (word1, word2) {
	return join(word1) === word2.join(word2)
}

// 方法二：遍历
var arrayStringsAreEqual = function (word1, word2) {
	let p1 = 0,
		p2 = 0,
		i = 0,
		j = 0
	while (p1 < word1.length && p2 < word2.length) {
		if (word1[p1][i] !== word2[p2][j]) return false
		i++
		if (i === word1[p1].length) {
			p1++
			i = 0
		}
		j++
		if (j === word2[p2].length) {
			p2++
			j = 0
		}
	}
	return p1 === word1.length && p2 === word2.length
}
